﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SDT.Model
{
    public class OrganizationManager
    {
        public static Organization GetOne(int id)
        {
            SDTDataContext db = new SDTDataContext();
            var l = (from a in db.Organizations
                     where a.ID == id
                     select a).ToList();

            return (l != null && l.Count > 0) ? l.First() : null;
        }
        public static string GetCodeByUser()
        {
            var id = UserProfile.GetOrganizationID();
            if (id > 0) {
                var o = GetOne(id);
                return o != null && o.Code != null && o.Code != string.Empty ? o.Code : string.Empty;
            }
            return string.Empty;
        }
    }
}
